import axios from '@/libs/api.request'
import config from '@/config'

export const getGoodServiceTable = async (playload) => {
  const resp = await axios.request({
    url: config.apiUrl,
    params: {
      module: 'GoodService.view',
      ...playload
    },
    method: 'get'
  })
  return resp
}

export const editGoodServiceRecord = async (playload) => {
  let module_name = 'GoodService.add'
  if (playload.id && playload.id !== '') {
    module_name = 'GoodService.update'
  }
  const data = {
    module: module_name,
    ...playload
  }
  const resp = await axios.request({
    url: config.postUrl,
    data,
    method: 'post'
  })
  return resp
}

export const deleteGoodServiceRecord = async (playload) => {
  const data = {
    module: 'GoodService.del',
    ...playload
  }
  const resp = await axios.request({
    url: config.postUrl,
    data,
    method: 'post'
  })
  return resp
}

export const getGoodsTable = async (playload) => {
  const resp = await axios.request({
    url: config.apiUrl,
    params: {
      module: 'GoodService.goodList',
      ...playload
    },
    method: 'get'
  })
  return resp
}

export const getLostOrder = async (playload) => {
  const resp = await axios.request({
    url: config.apiUrl,
    params: {
      module: 'GoodService.lostOrder',
      ...playload
    },
    method: 'get'
  })
  return resp
}

export const getSellOrder = async (playload) => {
  const resp = await axios.request({
    url: config.apiUrl,
    params: {
      module: 'GoodService.sellOrder',
      ...playload
    },
    method: 'get'
  })
  return resp
}

export const getWantOrder = async (playload) => {
  const resp = await axios.request({
    url: config.apiUrl,
    params: {
      module: 'GoodService.wantOrder',
      ...playload
    },
    method: 'get'
  })
  return resp
}

export const getSellMoneyOrder = async (playload) => {
  const resp = await axios.request({
    url: config.apiUrl,
    params: {
      module: 'GoodService.sellMoneyOrder',
      ...playload
    },
    method: 'get'
  })
  return resp
}

export const getOrderRate = async (playload) => {
  const resp = await axios.request({
    url: config.apiUrl,
    params: {
      module: 'GoodService.orderRateOrder',
      ...playload
    },
    method: 'get'
  })
  return resp
}

export const getLostRate = async (playload) => {
  const resp = await axios.request({
    url: config.apiUrl,
    params: {
      module: 'GoodService.lostRateOrder',
      ...playload
    },
    method: 'get'
  })
  return resp
}
